﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace HamcoWcs.DAL.Migrations
{
    public partial class A2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Bay",
                table: "node_info");

            migrationBuilder.DropColumn(
                name: "ExcuteSrm",
                table: "node_info");

            migrationBuilder.DropColumn(
                name: "PlcName",
                table: "node_info");

            migrationBuilder.DropColumn(
                name: "WmsNodeName",
                table: "node_info");

            migrationBuilder.RenameColumn(
                name: "ToWmsNode",
                table: "path_info",
                newName: "ToNode");

            migrationBuilder.RenameColumn(
                name: "FromWmsNode",
                table: "path_info",
                newName: "FromNode");

            migrationBuilder.AlterTable(
                name: "node_info",
                comment: "路径模块-节点信息",
                oldComment: "路径模块-点信息")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "NodeName",
                table: "node_info",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                comment: "节点名（上位名称）",
                oldClrType: typeof(string),
                oldType: "varchar(30)",
                oldMaxLength: 30,
                oldComment: "点位名")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "NextNode",
                table: "node_info",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                defaultValue: "",
                comment: "下一个节点 ‘；’分割",
                oldClrType: typeof(string),
                oldType: "varchar(255)",
                oldMaxLength: 255,
                oldNullable: true,
                oldComment: "下一节点名：多节点用;分开")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "DeviceType",
                table: "node_info",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                defaultValue: "",
                comment: "节点设备类型",
                oldClrType: typeof(string),
                oldType: "varchar(30)",
                oldMaxLength: 30,
                oldNullable: true,
                oldComment: "设备类型:Con、Srm、Agv")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "AlternateNode",
                table: "node_info",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                defaultValue: "",
                comment: "备用节点")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "InName",
                table: "node_info",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                defaultValue: "",
                comment: "入库端设备名")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "OutName",
                table: "node_info",
                type: "varchar(100)",
                maxLength: 100,
                nullable: false,
                defaultValue: "",
                comment: "出库端设备名")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_node_info_NodeName",
                table: "node_info",
                column: "NodeName",
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_node_info_NodeName",
                table: "node_info");

            migrationBuilder.DropColumn(
                name: "AlternateNode",
                table: "node_info");

            migrationBuilder.DropColumn(
                name: "InName",
                table: "node_info");

            migrationBuilder.DropColumn(
                name: "OutName",
                table: "node_info");

            migrationBuilder.RenameColumn(
                name: "ToNode",
                table: "path_info",
                newName: "ToWmsNode");

            migrationBuilder.RenameColumn(
                name: "FromNode",
                table: "path_info",
                newName: "FromWmsNode");

            migrationBuilder.AlterTable(
                name: "node_info",
                comment: "路径模块-点信息",
                oldComment: "路径模块-节点信息")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "NodeName",
                table: "node_info",
                type: "varchar(30)",
                maxLength: 30,
                nullable: false,
                comment: "点位名",
                oldClrType: typeof(string),
                oldType: "varchar(100)",
                oldMaxLength: 100,
                oldComment: "节点名（上位名称）")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "NextNode",
                table: "node_info",
                type: "varchar(255)",
                maxLength: 255,
                nullable: true,
                comment: "下一节点名：多节点用;分开",
                oldClrType: typeof(string),
                oldType: "varchar(100)",
                oldMaxLength: 100,
                oldComment: "下一个节点 ‘；’分割")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "DeviceType",
                table: "node_info",
                type: "varchar(30)",
                maxLength: 30,
                nullable: true,
                comment: "设备类型:Con、Srm、Agv",
                oldClrType: typeof(string),
                oldType: "varchar(100)",
                oldMaxLength: 100,
                oldComment: "节点设备类型")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<int>(
                name: "Bay",
                table: "node_info",
                type: "int",
                nullable: false,
                defaultValue: 0,
                comment: "站台列");

            migrationBuilder.AddColumn<string>(
                name: "ExcuteSrm",
                table: "node_info",
                type: "varchar(255)",
                maxLength: 255,
                nullable: true,
                comment: "堆垛机名")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "PlcName",
                table: "node_info",
                type: "varchar(30)",
                maxLength: 30,
                nullable: true,
                comment: "Plc名")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "WmsNodeName",
                table: "node_info",
                type: "varchar(30)",
                maxLength: 30,
                nullable: true,
                comment: "Wms点位名")
                .Annotation("MySql:CharSet", "utf8mb4");
        }
    }
}
